﻿#include "SqBTree.h"

//二叉树的顺序存储表示
int createSqBTree(SqBTree& BT, char a[][3], int  n)
{
	int i, j, k = 0;
	for (i = 0; i < maxSize; i++)
	{
		BT.data[i] = '#';
	}
	BT.data[k] = a[0][0];
	for (i = 0; i < n; i++)
	{
		for (j = 0; j <= k; j++)
		{
			if (a[i][0] == BT.data[j])
			{
				if (a[i][2] == '0')
				{
					BT.data[2 * j + 1] = a[i][1];
					k = 2 * j + 1;
					break;
				}
				else
				{
					BT.data[2 * j + 2] = a[i][1];
					k = 2 * j + 2;
					break;
				}
			}
		}
	}
	BT.n = n;
	return k;
}


//void main()
//{
//	char S[maxSize][3] = { {'A','B','0'},{'A','C','1'},{'B','D','0'},{'B','E','1'},
//	{'C','F','0'},{'C','G','1'},{'E','H','0'},{'F','I','0'},{'F','J','1'} };
//	SqBTree T;
//	int i, m = 0, n = 9;
//	m = createSqBTree(T, S, n);
//	for (i = 0; i <= m; i++)
//	{
//		printf("%c\n", T.data[i]);
//	}
//}